package cn.edu.neusoft.yyd208.foodorder.activity;

import android.content.Context;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;

import cn.edu.neusoft.yyd208.foodorder.R;

public abstract class BaseActivity extends AppCompatActivity {
    protected int layout_file=R.layout.activity_main;
    //protected int layout_file1=R.layout.activity_food_list;

    abstract void initView();
    abstract void initEvent();
    abstract void initData();
    void setLayout_file(int layout_file){
        setContentView(layout_file);
    }
/*void setLayout_file1(int layout_file1){
    setContentView(layout_file1);
}*/
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setLayout_file(layout_file);
        //setLayout_file1(layout_file1);
        initView();
        initEvent();
        initData();
    }
    public String getUser_name(){
        SharedPreferences sp;
        sp=getSharedPreferences("userInfo", Context.MODE_PRIVATE);
        return sp.getString("username","");
    }
    public String getUser_userpass(){
        SharedPreferences sp;
        sp=getSharedPreferences("userInfo", Context.MODE_PRIVATE);
        return sp.getString("userpass","");

    }
    public Boolean getUser_remember(){
        SharedPreferences sp;
        sp=getSharedPreferences("userInfo", Context.MODE_PRIVATE);
        return sp.getBoolean("remember",false);

    }
    public String getUser_userid(){
        SharedPreferences sp;
        sp=getSharedPreferences("userInfo", Context.MODE_PRIVATE);
        return sp.getString("userid","");

    }
    public void showToast(String content){
        Toast.makeText(this,content,Toast.LENGTH_SHORT).show();
        //Toast.makeText(this,content,Toast.LENGTH_LONG).show();
    }
}
